﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using CoiffeurProject.Utils;
using System.Windows.Media.Imaging;
using System.Windows.Media;
using System.Windows.Input;

namespace CoiffeurProject.UserControls
{
    #region Ticket Button

    internal class TicketButton
    {
        Grid main_container;
        Image rollover;
        Button button;
        Label label;

        internal TicketButton(Thickness margin, string button_label, string button_icon_uri,
            Action<object, RoutedEventArgs> click_event_handler)
        {
            main_container = new Grid()
            {
                Height = 110,
                Width = 124,
                Margin = margin,
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top
            };

            rollover = new Image()
            {
                Source = new BitmapImage(new Uri(ImagesPath.PressedIcon)),
                Height = 98,
                Width = 115,
                Visibility = Visibility.Hidden,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
                Stretch = Stretch.Fill
            };

            Grid.SetRow(rollover, 0);
            Grid.SetColumn(rollover, 0);
            main_container.Children.Add(rollover);

            label = new Label()
            {
                Content = button_label,
                VerticalAlignment = VerticalAlignment.Bottom,
                HorizontalContentAlignment = HorizontalAlignment.Center,
                Margin = new Thickness(0, 0, 0, 5)
            };

            Grid.SetRow(label, 0);
            Grid.SetColumn(label, 0);
            main_container.Children.Add(label);

            button = new Button()
            {
                Content = new Image()
                {
                    Source = new BitmapImage(new Uri(button_icon_uri)),
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment = VerticalAlignment.Center,
                    Stretch = Stretch.None,
                    Margin = new Thickness(0, 0, 0, 12)
                },
                Height = 110,
                Width = 124,
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Center,
            };

            button.MouseEnter += new MouseEventHandler(button_MouseEnter);
            button.MouseLeave += new MouseEventHandler(button_MouseLeave);
            button.Click += new RoutedEventHandler(click_event_handler);
            button.SetResourceReference(Button.StyleProperty, "NoChromeButton");

            Grid.SetRow(button, 0);
            Grid.SetColumn(button, 0);
            main_container.Children.Add(button);
        }

        void button_MouseLeave(object sender, MouseEventArgs e)
        {
            rollover.Visibility = Visibility.Hidden;
        }

        void button_MouseEnter(object sender, MouseEventArgs e)
        {
            rollover.Visibility = Visibility.Visible;
        }

        internal Grid MainContainer
        {
            get { return main_container; }
        }
    }

    #endregion
}
